#ifndef __singleton__
#define __singleton__
#endif

/*---------------------------------------------------------------------------*/

class Singleton;

/*---------------------------------------------------------------------------*/

class SingletonDestroyer
{
public:
	~SingletonDestroyer();
	void init( Singleton* p );
private:
	Singleton* p_instance;
};

/*---------------------------------------------------------------------------*/

class Singleton
{
public:
	static Singleton* getInstance();
	void set( int a );
	int get();
protected:
	Singleton();
	~Singleton();
	Singleton( const Singleton& );
	Singleton& operator=( Singleton& );
	friend class SingletonDestroyer;
private:
	static Singleton* p_instance;
	static SingletonDestroyer destroyer;
	int _a;
};

/*---------------------------------------------------------------------------*/
